<template>
	<view class="wrap">
		<u-alert-tips type="warning" :title="'错误信息'" :description="msg"></u-alert-tips>
		<u-alert-tips type="warning" :title="'错误信息'" :description="msg1"></u-alert-tips>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				msg:'',
				msg1:''
			}
		},
		onLoad() {
			this.addRandomData();
			this.loadStatus = "nomore";
		},
		methods: {
			addRandomData() {
				this.loadStatus = "loading";
				let _this=this;
				try{
					uniCloud.callFunction({
					    name: 'recipe',
					    data: { a: 1 },
						success(res){_this.msg=JSON.stringify(res)},
						fail(error){_this.msg=JSON.stringify(error)},
						complete(){}
					});
				}catch(e){
					this.msg=JSON.stringify(e)
					//TODO handle the exception
				}
				
				uni.request({
				    url: "https://api.bspapp.com",
				    method: 'GET',
				    complete() {
				        uni.hideLoading();
				    },
				    success(res) {
				       _this.msg1=JSON.stringify(res)
				    },
				    fail(error) {
						_this.msg1=JSON.stringify(error)
					}
				});
				
				
				
			},
			toRecipeDetail(recipe_code) {
				uni.navigateTo({
					url: '/pages/recipe/detail?recipe_code=' + recipe_code,
					success(res) {
						console.log(res);
					},
					fail(err) {
						console.log(err);
					}
				});
			}
		}
	}
</script>

<style>
	/* page不能写带scope的style标签中，否则无效 */
	page {
		background-color: rgb(240, 240, 240);
	}
</style>

<style lang="scss" scoped>
	.demo-warter {
		border-radius: 8px;
		margin: 5px;
		background-color: #ffffff;
		padding: 8px;
		position: relative;
	}

	.u-close {
		position: absolute;
		top: 32rpx;
		right: 32rpx;
	}

	.demo-image {
		width: 100%;
		border-radius: 4px;
	}

	.demo-title {
		font-size: 30rpx;
		margin-top: 5px;
		color: $u-main-color;
	}

	.demo-tag {
		display: flex;
		margin-top: 5px;
	}

	.demo-tag-owner {
		background-color: $u-type-error;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		padding: 4rpx 14rpx;
		border-radius: 50rpx;
		font-size: 20rpx;
		line-height: 1;
	}

	.demo-tag-text {
		border: 1px solid $u-type-primary;
		color: $u-type-primary;
		margin-left: 10px;
		border-radius: 50rpx;
		line-height: 1;
		padding: 4rpx 14rpx;
		display: flex;
		align-items: center;
		border-radius: 50rpx;
		font-size: 20rpx;
	}

	.demo-price {
		font-size: 30rpx;
		color: $u-type-error;
		margin-top: 5px;
	}

	.demo-shop {
		font-size: 22rpx;
		color: $u-tips-color;
		margin-top: 5px;
	}
</style>
